﻿@model ViewModelResult
@{
   
    var f = Model.Forum;

    var _topics = Model.List as List<Topic>;

    var _posts = ForumContext.GetMvcText(LanguageSection.TOPICS, "POSTS");
    var _views = ForumContext.GetMvcText(LanguageSection.TOPICS, "VIEWS");

}
@if (Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Both || Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Top)
{
    @Html.Partial("_ButtonPageRender", Model)
}
@if (f != null)
{
    
    
         
    <div class="site-block dd-popup-menu" id="forum_search_panel">
        <form action="@ForumContext.GetAbsoluteUrl(ForumUrls.SEARCH)">
        <div class="header">
            @ForumContext.GetText(LanguageSection.SEARCH, "SEARCH_IN_FORUM")
        </div>
        <div class="site-block-content p-5">
            <input type="hidden" value="quick" name="do" />
            @Html.Hidden("f", f.ForumId)
            <input type="text" name="kwd" class="input search-input" />
        </div>
        </form>
        <div class="site-block-content p-5">
            @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.SEARCH), ForumContext.GetText(LanguageSection.SEARCH, "SEARCH_ADVANCED"))
        </div>
    </div>
    
    
    <div class="site-block dd-popup-menu" id="forum_options">
        <ul class="dd-menu">
            <li>
                @Html.Link(string.Format("{0}?Id={1}", ForumContext.GetAbsoluteUrl(ForumUrls.NEW_POST), f.ForumId), ForumContext.GetText(LanguageSection.TOPICS, "NEW_POST"))
            </li>
            <li>
                @Html.Link(string.Format("{0}?ForumId={1}", ForumContext.GetAbsoluteUrl(ForumUrls.SUBCRIBE), f.ForumId), ForumContext.GetText(LanguageSection.FORUM, "SUBCRIBE"))
            </li>
            <li>
                @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_FORUM, f.ParentId), ForumContext.GetText(LanguageSection.FORUM, "GO_PARENT_FORUM"))
            </li>
        </ul>
    </div>
    
     
}@*
<div class="page-title">
    <h1>
        @f.ForumName
    </h1>
    <p class="description">
        @f.Description
    </p>
</div>*@
<div class="site-block">
    <div class="header">
        @if (Model.Type != ResultType.Search)
        {
            <ul class="toolbar">
                <li class="dropdown {dropdown:{target:'#forum_search_panel'}}"><span>@ForumContext.GetText(LanguageSection.SEARCH, "PAGE_NAME")</span></li>
                <li class="dropdown {dropdown:{target:'#forum_options'}}"><span>@ForumContext.GetText(LanguageSection.FORUM, "OPTIONS")</span></li>
            </ul>
        }
        <h1>
            @ViewBag.ActiveUrl.Title
        </h1>
        <br class="empty" />
    </div>
    <ul class="list-view">
        <li class="caption">
            <div class="fl cell thread-info">
                <span class="block">
                    @ForumContext.GetText(LanguageSection.TOPICS, "TOPIC")
                </span>
            </div>
            <div class="fl cell thread-lastpost">
                <span class="block">
                    @ForumContext.GetText(LanguageSection.TOPICS, "LAST_POST")
                </span>
            </div>
            <div class="fl cell thread-stats">
                <span class="block">
                    @string.Format("{0} / {1}", _posts, _views)
                </span>
            </div>
            <br class="empty" />
        </li>
        @if (_topics != null)
        {
            foreach (var t in _topics)
            {

                var _priority = t.Priority > 0 ? t.Priority == (int)PriorityType.Sticky ? "sticky" : "notice" : string.Empty;

                string _style = "";
                string _class = string.Format("{0} {1} {2}", !string.IsNullOrWhiteSpace(t.Icon) ? "smile" : string.Empty, _priority, !t.IsApproved ? "queue" : string.Empty).Trim();
                if (!string.IsNullOrWhiteSpace(t.Icon))
                {
                    _style = string.Format("background-image:url('{0}{1}')", ForumContext.Configuration.SmilePath, t.Icon);

                }
            <li class="@_class">
                <div class="fl cell thread-info">
                    <div class="block">
                        @ForumContext.IconRender(t, f != null ? f.ForumId : -1)
                        <h3>
                            @if (!string.IsNullOrWhiteSpace(_priority))
                            {
                                @ForumContext.GetMvcText(LanguageSection.TOPICS, _priority)
                            }
                            @Html.Link(!string.IsNullOrWhiteSpace(t.RemoteUrl) ? t.RemoteUrl : ForumContext.ThreadLink(t.TopicId, t.TopicName), t.TopicName.Truncate(), new { @class = "subject", @style = _style })
                        </h3>
                        @Html.Raw(string.Format(ForumContext.GetText(LanguageSection.TOPICS, "POSTER"), t.UserName, ForumContext.GetAbsoluteUrl(ForumUrls.USER_INFO, t.UserName))),
                        @ForumContext.PrettyDate(t.Created)
                        @if (Model.Type == ResultType.Search)
                        {
                            <h4>
                                @ForumContext.GetMvcText(LanguageSection.TOPICS, "Forum")
                                @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_FORUM, t.ForumId), t.ForumName)
                            </h4>
                        }
                        @if (Model.IsMod)
                        {
                            <p>
                            <label><input type="checkbox" class="selected" value="@t.TopicId"/>#@t.TopicId</label>
                            </p>
                        }
                    </div>
                </div>
                <div class="fl cell thread-lastpost">
                    <div class="block">
                        @if (t.LastPostId > 0)
                        {


                            @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, t.LastPostId), ForumContext.PrettyDate(t.LastPosted), new { @class = "last-post post-date" })<br />

                            @Html.Raw(string.Format(ForumContext.GetText(LanguageSection.TOPICS, "POSTER"), t.LastUserName, ForumContext.GetAbsoluteUrl(ForumUrls.USER_INFO, t.LastUserName)))

                        }
                        else
                        {

                            @Html.Link(ForumContext.GetAbsoluteUrl(ForumUrls.FIND_POST, t.TopicId), ForumContext.PrettyDate(t.Created), new { @class = "last-post post-date" })<br />

                            @Html.Raw(string.Format(ForumContext.GetText(LanguageSection.TOPICS, "POSTER"), t.UserName, ForumContext.GetAbsoluteUrl(ForumUrls.USER_INFO, t.UserName)))
                        }
                    </div>
                </div>
                <div class="fl cell thread-stats">
                    <div class="block">
                        <p>@string.Format("{0}: {1}", _posts, t.Replies)</p>
                        <p>@string.Format("{0}: {1}", _views, t.Views)</p>
                    </div>
                </div>
                <br class="empty" />
            </li>
            }
        }
    </ul>
</div>
@if (Model.IsMod)
{
     @Html.Partial("_ModeratorTools", f)
    
    /*  @Html.RenderAction(string.Format("{0}?f={1}", "ModeratorTools",f.ForumId))*/
}
@if (Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Both || Model.ButtonPageRenderPosition == ButtonPageRenderPosition.Bottom)
{
    @Html.Partial("_ButtonPageRender", Model)
}
@Html.Partial("_TopicIconLegend")
